<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
      <!--TODO-->
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
      <el-form-item label="商品分类ID" prop="catId">
        <el-input v-model="dataForm.catId" placeholder="商品分类ID"></el-input>
      </el-form-item>
      <el-form-item label="品牌ID" prop="brandId">
        <el-input v-model="dataForm.brandId" placeholder="品牌ID"></el-input>
      </el-form-item>
      <el-form-item label="商家ID" prop="userId">
        <el-input v-model="dataForm.userId" placeholder="商家ID"></el-input>
      </el-form-item>
      <el-form-item label="GOODSN" prop="goodsSn">
        <el-input v-model="dataForm.goodsSn" placeholder="GOODSN"></el-input>
      </el-form-item>
      <el-form-item label="商品的名称" prop="goodsName">
        <el-input v-model="dataForm.goodsName" placeholder="商品的名称"></el-input>
      </el-form-item>
      <el-form-item label="是否是实物" prop="isReal">
        <el-input v-model="dataForm.isReal" placeholder="是否是实物"></el-input>
      </el-form-item>
      <el-form-item label="商品的简短描述" prop="goodsBrief">
        <el-input v-model="dataForm.goodsBrief" placeholder="商品的简短描述"></el-input>
      </el-form-item>
      <el-form-item label="商品的详细描述" prop="goodsDesc">
        <el-input v-model="dataForm.goodsDesc" placeholder="商品的详细描述"></el-input>
      </el-form-item>

      <el-form-item label="微缩图片" prop="goodsThumb">
        <!--<el-input v-model="dataForm.goodsThumb" placeholder="微缩图片"></el-input>-->
        <el-upload
          class="upload-demo"
          :action="url"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :on-success="successHandle"
          :file-list="fileList2"
          :limit="1"
          v-model="dataForm.goodsThumb"
          list-type="picture">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
        </el-upload>
      </el-form-item>
      <el-form-item label="大图片" prop="goodsImg">
        <!--<el-input v-model="dataForm.goodsImg" placeholder="大图片"></el-input>-->
        <el-upload
          class="upload-demo"
          :action="url"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :on-success="successHandle1"
          :file-list="fileList3"
          :limit="1"
          v-model="dataForm.goodsImg"
          list-type="picture">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
        </el-upload>
      </el-form-item>
      <el-form-item label="原始图片" prop="originalImg">
        <!--<el-input v-model="dataForm.originalImg" placeholder="原始图片"></el-input>-->
        <el-upload
          class="upload-demo"
          :action="url"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :on-success="successHandle2"
          :file-list="fileList4"
          :limit="1"
          v-model="dataForm.originalImg"
          list-type="picture">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
        </el-upload>
      </el-form-item>
      <el-form-item label="商品的产地" prop="goodsAdress">
        <el-input v-model="dataForm.goodsAdress" placeholder="商品的产地"></el-input>
      </el-form-item>
      <el-form-item label="商品的规格" prop="goodsFormat">
        <el-input v-model="dataForm.goodsFormat" placeholder="商品的规格"></el-input>
      </el-form-item>
      <el-form-item label="培训城市" prop="goodsCity">
        <el-input v-model="dataForm.goodsCity" placeholder="培训城市"></el-input>
      </el-form-item>
      <el-form-item label="商品的重量（千克）" prop="goodsWeight">
        <el-input v-model="dataForm.goodsWeight" placeholder="商品的重量（千克）"></el-input>
      </el-form-item>
      <el-form-item label="商品库存数量" prop="goodsNumber">
        <el-input v-model="dataForm.goodsNumber" placeholder="商品库存数量"></el-input>
      </el-form-item>
      <el-form-item label="该商品是否开放销售" prop="isOnSale">
        <el-input v-model="dataForm.isOnSale" placeholder="该商品是否开放销售"></el-input>
      </el-form-item>
      <el-form-item label="是否单独销售" prop="isAloneSale">
        <el-input v-model="dataForm.isAloneSale" placeholder="是否单独销售"></el-input>
      </el-form-item>
      <el-form-item label="市场售价" prop="marketPrice">
        <el-input v-model="dataForm.marketPrice" placeholder="市场售价"></el-input>
      </el-form-item>
      <el-form-item label="本店售价" prop="shopPrice">
        <el-input v-model="dataForm.shopPrice" placeholder="本店售价"></el-input>
      </el-form-item>
      <el-form-item label="会员售价" prop="memberPrice">
        <el-input v-model="dataForm.memberPrice" placeholder="会员售价"></el-input>
      </el-form-item>
      <el-form-item label="是否特价促销" prop="isPromote">
        <el-input v-model="dataForm.isPromote" placeholder="是否特价促销"></el-input>
      </el-form-item>
      <el-form-item label="促销价格开始日期" prop="promoteStartUtc">
        <el-input v-model="dataForm.promoteStartUtc" placeholder="促销价格开始日期"></el-input>
      </el-form-item>
      <el-form-item label="促销价格结束日期" prop="promoteEndUtc">
        <el-input v-model="dataForm.promoteEndUtc" placeholder="促销价格结束日期"></el-input>
      </el-form-item>
      <el-form-item label="促销价格" prop="promotePrice">
        <el-input v-model="dataForm.promotePrice" placeholder="促销价格"></el-input>
      </el-form-item>
      <el-form-item label="购买该商品可以使用的消费积分数量" prop="integral">
        <el-input v-model="dataForm.integral" placeholder="购买该商品可以使用的消费积分数量"></el-input>
      </el-form-item>
      <el-form-item label="红包抵扣金额" prop="isBonus">
        <el-input v-model="dataForm.isBonus" placeholder="红包抵扣金额"></el-input>
      </el-form-item>
      <el-form-item label="购买该商品时每笔成功交易赠送的消费积分数量" prop="giveIntegral">
        <el-input v-model="dataForm.giveIntegral" placeholder="购买该商品时每笔成功交易赠送的消费积分数量"></el-input>
      </el-form-item>
      <el-form-item label="购买该商品时每笔成功交易赠送的等级积分数量" prop="rankIntegral">
        <el-input v-model="dataForm.rankIntegral" placeholder="购买该商品时每笔成功交易赠送的等级积分数量"></el-input>
      </el-form-item>
      <el-form-item label="购买该商品时每笔成功交易赠送的红包类型" prop="bonusTypeId">
        <el-input v-model="dataForm.bonusTypeId" placeholder="购买该商品时每笔成功交易赠送的红包类型"></el-input>
      </el-form-item>
      <el-form-item label="是否需要邮递" prop="isShipping">
        <el-input v-model="dataForm.isShipping" placeholder="是否需要邮递"></el-input>
      </el-form-item>
      <el-form-item label="商品点击数即浏览量" prop="clickCount">
        <el-input v-model="dataForm.clickCount" placeholder="商品点击数即浏览量"></el-input>
      </el-form-item>
      <el-form-item label="是否是精品；" prop="isBest">
        <el-input v-model="dataForm.isBest" placeholder="是否是精品；"></el-input>
      </el-form-item>
      <el-form-item label="是否是新品；" prop="isNew">
        <el-input v-model="dataForm.isNew" placeholder="是否是新品；"></el-input>
      </el-form-item>
      <el-form-item label="是否是热销；" prop="isHot">
        <el-input v-model="dataForm.isHot" placeholder="是否是热销；"></el-input>
      </el-form-item>
      <el-form-item label="商品状态；" prop="status">
        <el-input v-model="dataForm.status" placeholder="商品状态；"></el-input>
      </el-form-item>
      <el-form-item label="商品评价平均分数即评分；" prop="score">
        <el-input v-model="dataForm.score" placeholder="商品评价平均分数即评分；"></el-input>
      </el-form-item>
      <el-form-item label="商品的商家备注，仅商家可见" prop="sellerNote">
        <el-input v-model="dataForm.sellerNote" placeholder="商品的商家备注，仅商家可见"></el-input>
      </el-form-item>
      <el-form-item label="操作员" prop="operator">
        <el-input v-model="dataForm.operator" placeholder="操作员"></el-input>
      </el-form-item>
      <!--<el-form-item label="创建即上传时间" prop="createUtc">
        <el-input v-model="dataForm.createUtc" placeholder="创建即上传时间"></el-input>
      </el-form-item>
      <el-form-item label="修改即更新时间" prop="modifyUtc">
        <el-input v-model="dataForm.modifyUtc" placeholder="修改即更新时间"></el-input>
      </el-form-item>
      <el-form-item label="是否删除" prop="isDeleted">
        <el-input v-model="dataForm.isDeleted" placeholder="是否删除"></el-input>
      </el-form-item>-->
      <!--<el-form-item label="创建即上传时间" prop="createUtc">
        &lt;!&ndash;<el-input v-model="dataForm.createUtc" placeholder="创建即上传时间"></el-input>&ndash;&gt;
        <el-date-picker
          v-model="dataForm.createUtc"

          format="yyyy-MM-dd HH:mm:ss"
        >
        </el-date-picker>
      </el-form-item>-->


    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  import isInteger from 'lodash/isInteger'
  import moment from 'moment'
  export default {
    data () {
      return {
        baseUrl: 'http://localhost:8080/renren-fast',
        fileListItem1Name: '',
        fileListItem1url: '',
        url: this.$http.adornUrl(`/sys/oss/upload?token=${this.$cookie.get('token')}`),
        fileList2: [
          {
            name: '',
            url: ''
          }
        ],
        fileList3: [
          {
            name: '',
            url: ''
          }
        ],
        fileList4: [
          {
            name: '',
            url: ''
          }
        ],
        visible: false,
        dataForm: {
          id: 0,
          catId: '',
          brandId: '',
          userId: '',
          goodsSn: '',
          goodsName: '',
          isReal: '',
          goodsBrief: '',
          goodsDesc: '',
          goodsThumb: '',
          goodsImg: '',
          originalImg: '',
          goodsAdress: '',
          goodsFormat: '',
          goodsCity: '',
          goodsWeight: '',
          goodsNumber: '',
          isOnSale: '',
          isAloneSale: '',
          marketPrice: '',
          shopPrice: '',
          memberPrice: '',
          isPromote: '',
          promoteStartUtc: '',
          promoteEndUtc: '',
          promotePrice: '',
          integral: '',
          isBonus: '',
          giveIntegral: '',
          rankIntegral: '',
          bonusTypeId: '',
          isShipping: '',
          clickCount: '',
          isBest: '',
          isNew: '',
          isHot: '',
          status: '',
          score: '',
          sellerNote: '',
          operator: '',
          createUtc: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
          modifyUtc: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
          isDeleted: '',
          version: ''
        },
        dataRule: {
          catId: [
            { required: true, message: '商品分类ID不能为空', trigger: 'blur' }
          ],
          brandId: [
            { required: true, message: '品牌ID不能为空', trigger: 'blur' }
          ],
          userId: [
            { required: true, message: '商家ID不能为空', trigger: 'blur' }
          ],
          goodsSn: [
            { required: true, message: 'GOODSN不能为空', trigger: 'blur' }
          ],
          goodsName: [
            { required: true, message: '商品的名称不能为空', trigger: 'blur' }
          ],
          isReal: [
            { required: true, message: '是否是实物不能为空', trigger: 'blur' }
          ],
          goodsBrief: [
            { required: true, message: '商品的简短描述不能为空', trigger: 'blur' }
          ],
          goodsDesc: [
            { required: true, message: '商品的详细描述不能为空', trigger: 'blur' }
          ],
          goodsThumb: [
            { required: true, message: '微缩图片不能为空', trigger: 'blur' }
          ],
          goodsImg: [
            { required: true, message: '大图片不能为空', trigger: 'blur' }
          ],
          originalImg: [
            { required: true, message: '原始图片不能为空', trigger: 'blur' }
          ],
          goodsAdress: [
            { required: true, message: '商品的产地不能为空', trigger: 'blur' }
          ],
          goodsFormat: [
            { required: true, message: '商品的规格不能为空', trigger: 'blur' }
          ],
          goodsCity: [
            { required: true, message: '培训城市不能为空', trigger: 'blur' }
          ],
          goodsWeight: [
            { required: true, message: '商品的重量（千克）不能为空', trigger: 'blur' }
          ],
          goodsNumber: [
            { required: true, message: '商品库存数量不能为空', trigger: 'blur' }
          ],
          isOnSale: [
            { required: true, message: '该商品是否开放销售不能为空', trigger: 'blur' }
          ],
          isAloneSale: [
            { required: true, message: '是否单独销售不能为空', trigger: 'blur' }
          ],
          marketPrice: [
            { required: true, message: '市场售价不能为空', trigger: 'blur' }
          ],
          shopPrice: [
            { required: true, message: '本店售价不能为空', trigger: 'blur' }
          ],
          memberPrice: [
            { required: true, message: '会员售价不能为空', trigger: 'blur' }
          ],
          isPromote: [
            { required: true, message: '是否特价促销不能为空', trigger: 'blur' }
          ],
          promoteStartUtc: [
            { required: true, message: '促销价格开始日期不能为空', trigger: 'blur' }
          ],
          promoteEndUtc: [
            { required: true, message: '促销价格结束日期不能为空', trigger: 'blur' }
          ],
          promotePrice: [
            { required: true, message: '促销价格不能为空', trigger: 'blur' }
          ],
          integral: [
            { required: true, message: '购买该商品可以使用的消费积分数量不能为空', trigger: 'blur' }
          ],
          isBonus: [
            { required: true, message: '红包抵扣金额不能为空', trigger: 'blur' }
          ],
          giveIntegral: [
            { required: true, message: '购买该商品时每笔成功交易赠送的消费积分数量不能为空', trigger: 'blur' }
          ],
          rankIntegral: [
            { required: true, message: '购买该商品时每笔成功交易赠送的等级积分数量不能为空', trigger: 'blur' }
          ],
          bonusTypeId: [
            { required: true, message: '购买该商品时每笔成功交易赠送的红包类型不能为空', trigger: 'blur' }
          ],
          isShipping: [
            { required: true, message: '是否需要邮递不能为空', trigger: 'blur' }
          ],
          clickCount: [
            { required: true, message: '商品点击数即浏览量不能为空', trigger: 'blur' }
          ],
          isBest: [
            { required: true, message: '是否是精品；不能为空', trigger: 'blur' }
          ],
          isNew: [
            { required: true, message: '是否是新品；不能为空', trigger: 'blur' }
          ],
          isHot: [
            { required: true, message: '是否是热销；不能为空', trigger: 'blur' }
          ],
          status: [
            { required: true, message: '商品状态；不能为空', trigger: 'blur' }
          ],
          score: [
            { required: true, message: '商品评价平均分数即评分；不能为空', trigger: 'blur' }
          ],
          sellerNote: [
            { required: true, message: '商品的商家备注，仅商家可见不能为空', trigger: 'blur' }
          ],
          operator: [
            { required: true, message: '操作员不能为空', trigger: 'blur' }
          ],
          createUtc: [
            { required: true, message: '创建即上传时间不能为空', trigger: 'blur' }
          ],
          modifyUtc: [
            { required: true, message: '修改即更新时间不能为空', trigger: 'blur' }
          ],
          isDeleted: [
            { required: true, message: '是否删除不能为空', trigger: 'blur' }
          ],
          version: [
            { required: true, message: '版本号不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      handleRemove (file, fileList) {
        console.log(file, fileList)
      },
      onChange (file, fileList) {
//        this.fileList = fileList
      },
      handlePreview (file) {
        console.log(file)
      },
      // 上传成功
      successHandle (response, file, fileList) {
//        this.fileList = fileList
//        this.fileList2[0].url = response.url
        this.successNum++
        if (response && response.code === 0) {
          this.dataForm.goodsThumb = response.url
          if (this.num === this.successNum) {
            this.$confirm('操作成功, 是否继续操作?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).catch(() => {
              this.visible = false
            })
          }
        } else {
          this.$message.error(response.msg)
        }
      },
      successHandle1 (response, file, fileList) {
//        this.fileList = fileList
//        this.fileList2[0].url = response.url
        this.successNum++
        if (response && response.code === 0) {
          this.dataForm.goodsImg = response.url
          if (this.num === this.successNum) {
            this.$confirm('操作成功, 是否继续操作?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).catch(() => {
              this.visible = false
            })
          }
        } else {
          this.$message.error(response.msg)
        }
      },
      successHandle2 (response, file, fileList) {
//        this.fileList = fileList
//        this.fileList2[0].url = response.url
        this.successNum++
        if (response && response.code === 0) {
          this.dataForm.originalImg = response.url
          if (this.num === this.successNum) {
            this.$confirm('操作成功, 是否继续操作?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).catch(() => {
              this.visible = false
            })
          }
        } else {
          this.$message.error(response.msg)
        }
      },
      init (id) {
        this.dataForm.id = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            this.$http({
              url: this.$http.adornUrl('/generator/upkgoods/info' + (isInteger(this.dataForm.id) ? `/${this.dataForm.id}` : '')),
              method: 'get'
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.catId = data.upkGoods.catId
                this.dataForm.brandId = data.upkGoods.brandId
                this.dataForm.userId = data.upkGoods.userId
                this.dataForm.goodsSn = data.upkGoods.goodsSn
                this.dataForm.goodsName = data.upkGoods.goodsName
                this.dataForm.isReal = data.upkGoods.isReal
                this.dataForm.goodsBrief = data.upkGoods.goodsBrief
                this.dataForm.goodsDesc = data.upkGoods.goodsDesc
                this.dataForm.goodsThumb = data.upkGoods.goodsThumb
                this.dataForm.goodsImg = data.upkGoods.goodsImg
                this.dataForm.originalImg = data.upkGoods.originalImg
                this.dataForm.goodsAdress = data.upkGoods.goodsAdress
                this.dataForm.goodsFormat = data.upkGoods.goodsFormat
                this.dataForm.goodsCity = data.upkGoods.goodsCity
                this.dataForm.goodsWeight = data.upkGoods.goodsWeight
                this.dataForm.goodsNumber = data.upkGoods.goodsNumber
                this.dataForm.isOnSale = data.upkGoods.isOnSale
                this.dataForm.isAloneSale = data.upkGoods.isAloneSale
                this.dataForm.marketPrice = data.upkGoods.marketPrice
                this.dataForm.shopPrice = data.upkGoods.shopPrice
                this.dataForm.memberPrice = data.upkGoods.memberPrice
                this.dataForm.isPromote = data.upkGoods.isPromote
                this.dataForm.promoteStartUtc = data.upkGoods.promoteStartUtc
                this.dataForm.promoteEndUtc = data.upkGoods.promoteEndUtc
                this.dataForm.promotePrice = data.upkGoods.promotePrice
                this.dataForm.integral = data.upkGoods.integral
                this.dataForm.isBonus = data.upkGoods.isBonus
                this.dataForm.giveIntegral = data.upkGoods.giveIntegral
                this.dataForm.rankIntegral = data.upkGoods.rankIntegral
                this.dataForm.bonusTypeId = data.upkGoods.bonusTypeId
                this.dataForm.isShipping = data.upkGoods.isShipping
                this.dataForm.clickCount = data.upkGoods.clickCount
                this.dataForm.isBest = data.upkGoods.isBest
                this.dataForm.isNew = data.upkGoods.isNew
                this.dataForm.isHot = data.upkGoods.isHot
                this.dataForm.status = data.upkGoods.status
                this.dataForm.score = data.upkGoods.score
                this.dataForm.sellerNote = data.upkGoods.sellerNote
                this.dataForm.operator = data.upkGoods.operator
                this.dataForm.createUtc = data.upkGoods.createUtc
                this.dataForm.modifyUtc = data.upkGoods.modifyUtc
                this.dataForm.isDeleted = data.upkGoods.isDeleted
                this.dataForm.version = data.upkGoods.version
                this.fileList2 = [
                  {
                    url: 'http://localhost:8080/renren-fast' + this.dataForm.goodsThumb,
                    name: data.upkGoods.goodsName
                  }
                ]
                this.fileList3 = [
                  {
                    url: 'http://localhost:8080/renren-fast' + this.dataForm.goodsImg,
                    name: data.upkGoods.goodsName
                  }
                ]
                this.fileList4 = [
                  {
                    url: 'http://localhost:8080/renren-fast' + this.dataForm.originalImg,
                    name: data.upkGoods.goodsName
                  }
                ]
              }
            })
          } else {
            this.fileList2 = []
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            var params = {
              'id': this.dataForm.id || undefined,
              'catId': this.dataForm.catId,
              'brandId': this.dataForm.brandId,
              'userId': this.dataForm.userId,
              'goodsSn': this.dataForm.goodsSn,
              'goodsName': this.dataForm.goodsName,
              'isReal': this.dataForm.isReal,
              'goodsBrief': this.dataForm.goodsBrief,
              'goodsDesc': this.dataForm.goodsDesc,
              'goodsThumb': this.dataForm.goodsThumb,
              'goodsImg': this.dataForm.goodsImg,
              'originalImg': this.dataForm.originalImg,
              'goodsAdress': this.dataForm.goodsAdress,
              'goodsFormat': this.dataForm.goodsFormat,
              'goodsCity': this.dataForm.goodsCity,
              'goodsWeight': this.dataForm.goodsWeight,
              'goodsNumber': this.dataForm.goodsNumber,
              'isOnSale': this.dataForm.isOnSale,
              'isAloneSale': this.dataForm.isAloneSale,
              'marketPrice': this.dataForm.marketPrice,
              'shopPrice': this.dataForm.shopPrice,
              'memberPrice': this.dataForm.memberPrice,
              'isPromote': this.dataForm.isPromote,
              'promoteStartUtc': this.dataForm.promoteStartUtc,
              'promoteEndUtc': this.dataForm.promoteEndUtc,
              'promotePrice': this.dataForm.promotePrice,
              'integral': this.dataForm.integral,
              'isBonus': this.dataForm.isBonus,
              'giveIntegral': this.dataForm.giveIntegral,
              'rankIntegral': this.dataForm.rankIntegral,
              'bonusTypeId': this.dataForm.bonusTypeId,
              'isShipping': this.dataForm.isShipping,
              'clickCount': this.dataForm.clickCount,
              'isBest': this.dataForm.isBest,
              'isNew': this.dataForm.isNew,
              'isHot': this.dataForm.isHot,
              'status': this.dataForm.status,
              'score': this.dataForm.score,
              'sellerNote': this.dataForm.sellerNote,
              'operator': this.dataForm.operator,
              'createUtc': this.dataForm.createUtc,
              'modifyUtc': this.dataForm.modifyUtc,
              'isDeleted': this.dataForm.isDeleted,
              'version': this.dataForm.version
            }
            var tick = !this.dataForm.id ? this.$http({
              url: this.$http.adornUrl('/generator/upkgoods/save'),
              method: 'post',
              data: this.$http.adornData(params)
            }) : this.$http({
              url: this.$http.adornUrl('/generator/upkgoods/update'),
              method: 'post',
              data: this.$http.adornData(params)
            })
            tick.then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
